<template>
  <div>
    <h1>当前销售员：{{salesman.name}}</h1>
    <!-- <button @click="init">初始化</button> -->
    <el-table :data="customers" border style="width: 100%">
      <el-table-column prop="_id" label="_id" width="180"> </el-table-column>
      <el-table-column prop="name" label="姓名" width="180"> </el-table-column>
      <el-table-column prop="age" label="年龄"> </el-table-column>
      <el-table-column prop="gender" label="性别"> </el-table-column>
      <el-table-column prop="insures" label="保险产品"> </el-table-column>
      <el-table-column label="销售员">
        <template>
          <span style="margin-left: 10px">{{salesman.name}}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapState, mapActions, mapMutations } = createNamespacedHelpers(
  "salesmans"
);
export default {
  data() {
    return {
      salesman: "",
      salesmanobj: "",
      customers:[],
      name:'123'
    };
  },
  async created() {
    this.salesman = JSON.parse(localStorage.loginUser);
    const salesmanobj = (
      await this.receiveSalesmanById({ _id: this.salesman._id })
    )[0];
    this.salesmanobj = salesmanobj;
    this.customers = this.salesmanobj.customerId;
    // console.log(111111,this.customers);
    // console.log(1111111, salesmanobj);
  },
  methods: {
    ...mapActions(["receiveSalesmanById"]),
    init() {
      const admin = {
        name: "小明",
        isAdmins: false,
        _id: "5ff27d16a7f0811fa0dd4c69",
      };
      localStorage.loginUser = JSON.stringify(admin);
      console.log("okok");
    },
  },
};
</script>

<style>
</style>